﻿Imports Tom0014
Imports Tom0014TableAdapters
Partial Class Registro_genealogia
    Inherits System.Web.UI.Page
    Dim genealogiaAnimal As New GenealogiaTableAdapter
    'Dim sEditPage As String = "~/Registro/detalles.aspx?animal="
    'Dim sCriasPage As String = "~/Registro/_crias.aspx?animal="
    Dim sFlag As String = "~/images/flag.png"
    Dim sFlagOf As String = "~/images/attibutes.png"
    Dim strNoRegistrado As String = "NO REGISTRADO"
    Dim iAnimal As Integer
    Dim dt1, dt2, dt3, dt4, dt5, dt6, dt7, dt8, dt9, dt10, _
        dt11, dt12, dt13, dt14, dt15, dt16, dt17, dt18, dt19, dt20, _
        dt21, dt22, dt23, dt24, dt25, dt26, dt27, dt28, dt29, dt30, _
        dt31, animal As New GenealogiaDataTable

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not IsPostBack Then
            Try
                iAnimal = CType(Request.QueryString("animal"), Integer) ' Obten el animal a trabajar
            Catch ex As Exception
                iAnimal = 0
                Exit Sub
            End Try
        End If

        If iAnimal = 0 Then Exit Sub
        Call DoGenealogia(iAnimal)
        animal = genealogiaAnimal.GetAnimalById(iAnimal)
        lblAnimal.Text = animal(0).claveSNLA + " " + animal(0).nombre
        ' -- TITULO --
        lblClaveAnimal.Text = animal(0).claveSNLA
        lblNombreTitulo.Text = animal(0).nombre
        lblAnimalId.Text = animal(0).AnimalId
    End Sub

    Protected Sub DoGenealogia(ByVal iAnimal As Integer)
        If iAnimal <> 0 Then ' Se obtuvieron valores
            ' 1 *** A N I M A L ***
            hfDetalleId.Value = 0
            dt1 = genealogiaAnimal.GetAnimalById(iAnimal)
            If dt1.Rows.Count > 0 Then
                hlNombre1.Text = CType(dt1(0).nombre, String)
                'hlNombre1.NavigateUrl = sEditPage + CType(dt1(0).AnimalId, String)
                ' hlNombre1.CssClass = "detalles"
                lblNumero1.Text = CType(dt1(0).numero, String)
                lblLetra1.Text = CType(dt1(0).letra, String)
                lblAno1.Text = CType(dt1(0).ano, String)
                lblNotaAC1.Text = CType(dt1(0).tienta_ac, String)
                lblNotaAP1.Text = CType(dt1(0).tienta_ap, String)
                lblPelaje1.Text = CType(dt1(0).pelaje1, String)
                lblHierro1.Text = CType(dt1(0).hierro, String)
                'imgDetalle1.NavigateUrl = sCriasPage + CType(dt1(0).AnimalId, String)
                ' imgDetalle1.CssClass = "crias"
                hfCampo1.Value = dt1(0).AnimalId
            End If

            ' 2 *** P A D R E ***
            If dt1.Rows.Count > 0 Then
                dt2 = genealogiaAnimal.GetAnimalBySNLA("T", dt1(0).no_padre, dt1(0).ltra_padre, dt1(0).ano_padre)

            End If
            Call NivelToro(dt1, dt2, hlNombre2, lblNumero2, lblLetra2, lblAno2, lblNotaAC2, lblNotaAP2, lblPelaje2, lblHierro2, imgAvanza2, hfCampo2)

            ' 3 *** M A D R E ***
            If dt1.Rows.Count > 0 Then
                dt3 = genealogiaAnimal.GetAnimalBySNLA("V", dt1(0).no_madre, dt1(0).ltra_madre, dt1(0).ano_madre)
            End If
            Call NivelVaca(dt1, dt3, hlNombre3, lblNumero3, lblLetra3, lblAno3, lblNotaAC3, lblNotaAP3, lblPelaje3, lblHierro3, imgAvanza3, hfCampo3)

            ' 4 *** ABUELO PATERNO ***
            If dt2.Rows.Count > 0 Then
                dt4 = genealogiaAnimal.GetAnimalBySNLA("T", dt2(0).no_padre, dt2(0).ltra_padre, dt2(0).ano_padre)
            End If
            Call NivelToro(dt2, dt4, hlNombre4, lblNumero4, lblLetra4, lblAno4, lblNotaAC4, lblNotaAP4, lblPelaje4, lblHierro4, imgAvanza4, hfCampo4)

            ' 5 *** ABUELA PATERNA ***
            If dt2.Rows.Count > 0 Then
                dt5 = genealogiaAnimal.GetAnimalBySNLA("V", dt2(0).no_madre, dt2(0).ltra_madre, dt2(0).ano_madre)
            End If
            Call NivelVaca(dt2, dt5, hlNombre5, lblNumero5, lblLetra5, lblAno5, lblNotaAC5, lblNotaAP5, lblPelaje5, lblHierro5, imgAvanza5, hfCampo5)

            ' 6 *** ABUELO MATERNO ***
            If dt3.Rows.Count > 0 Then
                dt6 = genealogiaAnimal.GetAnimalBySNLA("T", dt3(0).no_padre, dt3(0).ltra_padre, dt3(0).ano_padre)
            End If
            Call NivelToro(dt3, dt6, hlNombre6, lblNumero6, lblLetra6, lblAno6, lblNotaAC6, lblNotaAP6, lblPelaje6, lblHierro6, imgAvanza6, hfCampo6)

            ' 7 *** ABUELA MATERNA ***
            If dt3.Rows.Count > 0 Then
                dt7 = genealogiaAnimal.GetAnimalBySNLA("V", dt3(0).no_madre, dt3(0).ltra_madre, dt3(0).ano_madre)

            End If
            Call NivelVaca(dt3, dt7, hlNombre7, lblNumero7, lblLetra7, lblAno7, lblNotaAC7, lblNotaAP7, lblPelaje7, lblHierro7, imgAvanza7, hfCampo7)

            ' 8 *** ABUELO MATERNO ***
            If dt4.Rows.Count > 0 Then
                dt8 = genealogiaAnimal.GetAnimalBySNLA("T", dt4(0).no_padre, dt4(0).ltra_padre, dt4(0).ano_padre)
            End If
            Call NivelToro(dt4, dt8, hlNombre8, lblNumero8, lblLetra8, lblAno8, lblNotaAC8, lblNotaAP8, imgAvanza8, hfCampo8)

            ' 9 *** ABUELA MATERNA ***
            If dt4.Rows.Count > 0 Then
                dt9 = genealogiaAnimal.GetAnimalBySNLA("V", dt4(0).no_madre, dt4(0).ltra_madre, dt4(0).ano_madre)
            End If
            Call NivelVaca(dt4, dt9, hlNombre9, lblNumero9, lblLetra9, lblAno9, lblNotaAC9, lblNotaAP9, imgAvanza9, hfCampo9)

            ' 10 *** ABUELO MATERNO ***
            If dt5.Rows.Count > 0 Then
                dt10 = genealogiaAnimal.GetAnimalBySNLA("T", dt5(0).no_padre, dt5(0).ltra_padre, dt5(0).ano_padre)
            End If
            Call NivelToro(dt5, dt10, hlNombre10, lblNumero10, lblLetra10, lblAno10, lblNotaAC10, lblNotaAP10, imgAvanza10, hfCampo10)

            ' 11 *** ABUELA MATERNA ***
            If dt5.Rows.Count > 0 Then
                dt11 = genealogiaAnimal.GetAnimalBySNLA("V", dt5(0).no_madre, dt5(0).ltra_madre, dt5(0).ano_madre)
            End If
            Call NivelVaca(dt5, dt11, hlNombre11, lblNumero11, lblLetra11, lblAno11, lblNotaAC11, lblNotaAP11, imgAvanza11, hfCampo11)

            ' 12 *** ABUELO MATERNO ***
            If dt6.Rows.Count > 0 Then
                dt12 = genealogiaAnimal.GetAnimalBySNLA("T", dt6(0).no_padre, dt6(0).ltra_padre, dt6(0).ano_padre)
            End If
            Call NivelToro(dt6, dt12, hlNombre12, lblNumero12, lblLetra12, lblAno12, lblNotaAC12, lblNotaAP12, imgAvanza12, hfCampo12)

            ' 13 *** ABUELA MATERNA ***
            If dt6.Rows.Count > 0 Then
                dt13 = genealogiaAnimal.GetAnimalBySNLA("V", dt6(0).no_madre, dt6(0).ltra_madre, dt6(0).ano_madre)
            End If
            Call NivelVaca(dt6, dt13, hlNombre13, lblNumero13, lblLetra13, lblAno13, lblNotaAC13, lblNotaAP13, imgAvanza13, hfCampo13)

            ' 14 *** ABUELO MATERNO ***
            If dt7.Rows.Count > 0 Then
                dt14 = genealogiaAnimal.GetAnimalBySNLA("T", dt7(0).no_padre, dt7(0).ltra_padre, dt7(0).ano_padre)
            End If
            Call NivelToro(dt7, dt14, hlNombre14, lblNumero14, lblLetra14, lblAno14, lblNotaAC14, lblNotaAP14, imgAvanza14, hfCampo14)

            ' 15 *** ABUELA MATERNA ***
            If dt7.Rows.Count > 0 Then
                dt15 = genealogiaAnimal.GetAnimalBySNLA("V", dt7(0).no_madre, dt7(0).ltra_madre, dt7(0).ano_madre)
            End If
            Call NivelVaca(dt7, dt15, hlNombre15, lblNumero15, lblLetra15, lblAno15, lblNotaAC15, lblNotaAP15, imgAvanza15, hfCampo15)

            ' 16 *** ABUELO MATERNO ***
            If dt8.Rows.Count > 0 Then
                dt16 = genealogiaAnimal.GetAnimalBySNLA("T", dt8(0).no_padre, dt8(0).ltra_padre, dt8(0).ano_padre)
            End If
            Call NivelToro(dt8, dt16, hlNombre16, lblNumero16, lblLetra16, lblAno16, imgAvanza16, hfCampo16)

            ' 17 *** ABUELA MATERNA ***
            If dt8.Rows.Count > 0 Then
                dt17 = genealogiaAnimal.GetAnimalBySNLA("V", dt8(0).no_madre, dt8(0).ltra_madre, dt8(0).ano_madre)
            End If
            Call NivelVaca(dt8, dt17, hlNombre17, lblNumero17, lblLetra17, lblAno17, imgAvanza17, hfCampo17)

            ' 18 *** ABUELO MATERNO ***
            If dt9.Rows.Count > 0 Then
                dt18 = genealogiaAnimal.GetAnimalBySNLA("T", dt9(0).no_padre, dt9(0).ltra_padre, dt9(0).ano_padre)
            End If
            Call NivelToro(dt9, dt18, hlNombre18, lblNumero18, lblLetra18, lblAno18, imgAvanza18, hfCampo18)

            ' 19 *** ABUELA MATERNA ***
            If dt9.Rows.Count > 0 Then
                dt19 = genealogiaAnimal.GetAnimalBySNLA("V", dt9(0).no_madre, dt9(0).ltra_madre, dt9(0).ano_madre)
            End If
            Call NivelVaca(dt9, dt19, hlNombre19, lblNumero19, lblLetra19, lblAno19, imgAvanza19, hfCampo19)

            ' 20 *** ABUELO MATERNO ***
            If dt10.Rows.Count > 0 Then
                dt20 = genealogiaAnimal.GetAnimalBySNLA("T", dt10(0).no_padre, dt10(0).ltra_padre, dt10(0).ano_padre)
            End If
            Call NivelToro(dt10, dt20, hlNombre20, lblNumero20, lblLetra20, lblAno20, imgAvanza20, hfCampo20)

            ' 21 *** ABUELA MATERNA ***
            If dt10.Rows.Count > 0 Then
                dt21 = genealogiaAnimal.GetAnimalBySNLA("V", dt10(0).no_madre, dt10(0).ltra_madre, dt10(0).ano_madre)
            End If
            Call NivelVaca(dt10, dt21, hlNombre21, lblNumero21, lblLetra21, lblAno21, imgAvanza21, hfCampo21)

            ' 22 *** ABUELO MATERNO ***
            If dt11.Rows.Count > 0 Then
                dt22 = genealogiaAnimal.GetAnimalBySNLA("T", dt11(0).no_padre, dt11(0).ltra_padre, dt11(0).ano_padre)
            End If
            Call NivelToro(dt11, dt22, hlNombre22, lblNumero22, lblLetra22, lblAno22, imgAvanza22, hfCampo22)

            ' 23 *** ABUELA MATERNA ***
            If dt11.Rows.Count > 0 Then
                dt23 = genealogiaAnimal.GetAnimalBySNLA("V", dt11(0).no_madre, dt11(0).ltra_madre, dt11(0).ano_madre)
            End If
            Call NivelVaca(dt11, dt23, hlNombre23, lblNumero23, lblLetra23, lblAno23, imgAvanza23, hfCampo23)

            ' 24 *** ABUELO MATERNO ***
            If dt12.Rows.Count > 0 Then
                dt24 = genealogiaAnimal.GetAnimalBySNLA("T", dt12(0).no_padre, dt12(0).ltra_padre, dt12(0).ano_padre)
            End If
            Call NivelToro(dt12, dt24, hlNombre24, lblNumero24, lblLetra24, lblAno24, imgAvanza24, hfCampo24)

            ' 25 *** ABUELA MATERNA ***
            If dt12.Rows.Count > 0 Then
                dt25 = genealogiaAnimal.GetAnimalBySNLA("V", dt12(0).no_madre, dt12(0).ltra_madre, dt12(0).ano_madre)
            End If
            Call NivelVaca(dt12, dt25, hlNombre25, lblNumero25, lblLetra25, lblAno25, imgAvanza25, hfCampo25)

            ' 26 *** ABUELO MATERNO ***
            If dt13.Rows.Count > 0 Then
                dt26 = genealogiaAnimal.GetAnimalBySNLA("T", dt13(0).no_padre, dt13(0).ltra_padre, dt13(0).ano_padre)
            End If
            Call NivelToro(dt13, dt26, hlNombre26, lblNumero26, lblLetra26, lblAno26, imgAvanza26, hfCampo26)

            ' 27 *** ABUELA MATERNA ***
            If dt13.Rows.Count > 0 Then
                dt27 = genealogiaAnimal.GetAnimalBySNLA("V", dt13(0).no_madre, dt13(0).ltra_madre, dt13(0).ano_madre)
            End If
            Call NivelVaca(dt13, dt27, hlNombre27, lblNumero27, lblLetra27, lblAno27, imgAvanza27, hfCampo27)

            ' 28 *** ABUELO MATERNO ***
            If dt14.Rows.Count > 0 Then
                dt28 = genealogiaAnimal.GetAnimalBySNLA("T", dt14(0).no_padre, dt14(0).ltra_padre, dt14(0).ano_padre)
            End If
            Call NivelToro(dt14, dt28, hlNombre28, lblNumero28, lblLetra28, lblAno28, imgAvanza28, hfCampo28)

            ' 29 *** ABUELA MATERNA ***
            If dt14.Rows.Count > 0 Then
                dt29 = genealogiaAnimal.GetAnimalBySNLA("V", dt14(0).no_madre, dt14(0).ltra_madre, dt14(0).ano_madre)
            End If
            Call NivelVaca(dt14, dt29, hlNombre29, lblNumero29, lblLetra29, lblAno29, imgAvanza29, hfCampo29)

            ' 30 *** ABUELO MATERNO ***
            If dt15.Rows.Count > 0 Then
                dt30 = genealogiaAnimal.GetAnimalBySNLA("T", dt15(0).no_padre, dt15(0).ltra_padre, dt15(0).ano_padre)
            End If
            Call NivelToro(dt15, dt30, hlNombre30, lblNumero30, lblLetra30, lblAno30, imgAvanza30, hfCampo30)

            ' 31 *** ABUELA MATERNA ***
            If dt15.Rows.Count > 0 Then
                dt31 = genealogiaAnimal.GetAnimalBySNLA("V", dt15(0).no_madre, dt15(0).ltra_madre, dt15(0).ano_madre)
            End If
            Call NivelVaca(dt15, dt31, hlNombre31, lblNumero31, lblLetra31, lblAno31, imgAvanza31, hfCampo31)
        End If
    End Sub
#Region "Funciones de Cambio Objeto"
    Protected Sub NivelVaca(ByRef dtAnterior As GenealogiaDataTable, ByRef dtNuevo As GenealogiaDataTable, _
                                ByRef hlNombre As HyperLink, _
                                ByRef lblNumero As Label, ByRef lblLetra As Label, _
                                ByRef lblAno As Label, ByRef lkBoton As ImageButton, ByRef hfCampo As HiddenField)

        If dtNuevo.Rows.Count > 0 Then
            hlNombre.Text = CType(dtNuevo(0).nombre, String)
            'hlNombre.NavigateUrl = sEditPage + CType(dtNuevo(0).AnimalId, String)
            'hlNombre.CssClass = "detalles"
            lblNumero.Text = CType(dtNuevo(0).numero, String)
            lblLetra.Text = CType(dtNuevo(0).letra, String)
            lblAno.Text = CType(dtNuevo(0).ano, String)
            lkBoton.Visible = True
            hfCampo.Value = CType(dtNuevo(0).AnimalId, String)
            'imgDetalle.Visible = True
            'imgDetalle.NavigateUrl = sCriasPage + CType(dtNuevo(0).AnimalId, String)
            'imgDetalle.CssClass = "crias"
        Else
            hlNombre.Text = strNoRegistrado
            hlNombre.CssClass = ""
            hlNombre.NavigateUrl = ""
            If dtAnterior.Rows.Count > 0 Then
                lblNumero.Text = CType(dtAnterior(0).no_madre, String)
                lblLetra.Text = CType(dtAnterior(0).ltra_madre, String)
                lblAno.Text = CType(dtAnterior(0).ano_madre, String)
            Else
                lblNumero.Text = ""
                lblLetra.Text = ""
                lblAno.Text = ""
            End If
            lkBoton.Visible = False
            hfCampo.Value = "0"
            'imgDetalle.Visible = False
        End If
    End Sub
    Protected Sub NivelToro(ByRef dtAnterior As GenealogiaDataTable, ByRef dtNuevo As GenealogiaDataTable, _
                            ByRef hlNombre As HyperLink, _
                            ByRef lblNumero As Label, ByRef lblLetra As Label, _
                            ByRef lblAno As Label, ByRef lkBoton As ImageButton, ByRef hfCampo As HiddenField)

        If dtNuevo.Rows.Count > 0 Then
            hlNombre.Text = CType(dtNuevo(0).nombre, String)
            'hlNombre.NavigateUrl = sEditPage + CType(dtNuevo(0).AnimalId, String)
            'hlNombre.CssClass = "detalles"
            lblNumero.Text = CType(dtNuevo(0).numero, String)
            lblLetra.Text = CType(dtNuevo(0).letra, String)
            lblAno.Text = CType(dtNuevo(0).ano, String)
            lkBoton.Visible = True
            hfCampo.Value = CType(dtNuevo(0).AnimalId, String)
            'imgDetalle.Visible = True
            'imgDetalle.NavigateUrl = sCriasPage + CType(dtNuevo(0).AnimalId, String)
            'imgDetalle.CssClass = "crias"
        Else
            hlNombre.Text = strNoRegistrado
            hlNombre.CssClass = ""
            hlNombre.NavigateUrl = ""
            If dtAnterior.Rows.Count > 0 Then
                lblNumero.Text = CType(dtAnterior(0).no_padre, String)
                lblLetra.Text = CType(dtAnterior(0).ltra_padre, String)
                lblAno.Text = CType(dtAnterior(0).ano_padre, String)
            Else
                lblNumero.Text = ""
                lblLetra.Text = ""
                lblAno.Text = ""
            End If
            lkBoton.Visible = False
            hfCampo.Value = "0"
            'imgDetalle.Visible = False
        End If
    End Sub
    Protected Sub NivelVaca(ByRef dtAnterior As GenealogiaDataTable, ByRef dtNuevo As GenealogiaDataTable, _
                            ByRef hlNombre As HyperLink, _
                            ByRef lblNumero As Label, ByRef lblLetra As Label, _
                            ByRef lblAno As Label, ByRef lblNotaAc As Label, _
                            ByRef lblNotaAP As Label, ByRef lkBoton As ImageButton, ByRef hfCampo As HiddenField)

        If dtNuevo.Rows.Count > 0 Then
            hlNombre.Text = CType(dtNuevo(0).nombre, String)
            'hlNombre.NavigateUrl = sEditPage + CType(dtNuevo(0).AnimalId, String)
            'hlNombre.CssClass = "detalles"
            lblNumero.Text = CType(dtNuevo(0).numero, String)
            lblLetra.Text = CType(dtNuevo(0).letra, String)
            lblAno.Text = CType(dtNuevo(0).ano, String)
            lblNotaAc.Text = CType(dtNuevo(0).tienta_ac, String)
            lblNotaAP.Text = CType(dtNuevo(0).tienta_ap, String)
            lkBoton.Visible = True
            hfCampo.Value = CType(dtNuevo(0).AnimalId, String)
            ' imgDetalle.Visible = True
            'imgDetalle.NavigateUrl = sCriasPage + CType(dtNuevo(0).AnimalId, String)
            'imgDetalle.CssClass = "crias"
        Else
            hlNombre.Text = strNoRegistrado
            hlNombre.CssClass = ""
            hlNombre.NavigateUrl = ""
            If dtAnterior.Rows.Count > 0 Then
                lblNumero.Text = CType(dtAnterior(0).no_madre, String)
                lblLetra.Text = CType(dtAnterior(0).ltra_madre, String)
                lblAno.Text = CType(dtAnterior(0).ano_madre, String)
            Else
                lblNumero.Text = ""
                lblLetra.Text = ""
                lblAno.Text = ""
            End If
            lblNotaAc.Text = ""
            lblNotaAP.Text = ""
            lkBoton.Visible = False
            hfCampo.Value = "0"
            'imgDetalle.Visible = False
        End If
    End Sub
    Protected Sub NivelToro(ByRef dtAnterior As GenealogiaDataTable, ByRef dtNuevo As GenealogiaDataTable, _
                            ByRef hlNombre As HyperLink, _
                            ByRef lblNumero As Label, ByRef lblLetra As Label, _
                            ByRef lblAno As Label, ByRef lblNotaAc As Label, _
                            ByRef lblNotaAP As Label, ByRef lkBoton As ImageButton, ByRef hfCampo As HiddenField)

        If dtNuevo.Rows.Count > 0 Then
            hlNombre.Text = CType(dtNuevo(0).nombre, String)
            'hlNombre.NavigateUrl = sEditPage + CType(dtNuevo(0).AnimalId, String)
            'hlNombre.CssClass = "detalles"
            lblNumero.Text = CType(dtNuevo(0).numero, String)
            lblLetra.Text = CType(dtNuevo(0).letra, String)
            lblAno.Text = CType(dtNuevo(0).ano, String)
            lblNotaAc.Text = CType(dtNuevo(0).tienta_ac, String)
            lblNotaAP.Text = CType(dtNuevo(0).tienta_ap, String)
            lkBoton.Visible = True
            hfCampo.Value = CType(dtNuevo(0).AnimalId, String)
            'imgDetalle.Visible = True
            'imgDetalle.NavigateUrl = sCriasPage + CType(dtNuevo(0).AnimalId, String)
            'imgDetalle.CssClass = "crias"
        Else
            hlNombre.Text = strNoRegistrado
            hlNombre.CssClass = ""
            hlNombre.NavigateUrl = ""
            If dtAnterior.Rows.Count > 0 Then
                lblNumero.Text = CType(dtAnterior(0).no_padre, String)
                lblLetra.Text = CType(dtAnterior(0).ltra_padre, String)
                lblAno.Text = CType(dtAnterior(0).ano_padre, String)
            Else
                lblNumero.Text = ""
                lblLetra.Text = ""
                lblAno.Text = ""
            End If
            lblNotaAc.Text = ""
            lblNotaAP.Text = ""
            lkBoton.Visible = False
            hfCampo.Value = "0"
            'imgDetalle.Visible = False
        End If
    End Sub
    Protected Sub NivelVaca(ByRef dtAnterior As GenealogiaDataTable, ByRef dtNuevo As GenealogiaDataTable, _
                            ByRef hlNombre As HyperLink, _
                            ByRef lblNumero As Label, ByRef lblLetra As Label, _
                            ByRef lblAno As Label, ByRef lblNotaAc As Label, _
                            ByRef lblNotaAP As Label, ByRef lblPelaje As Label, _
                            ByRef lblHierro As Label, ByRef lkBoton As ImageButton, ByRef hfCampo As HiddenField)

        If dtNuevo.Rows.Count > 0 Then
            hlNombre.Text = CType(dtNuevo(0).nombre, String)
            'hlNombre.NavigateUrl = sEditPage + CType(dtNuevo(0).AnimalId, String)
            'hlNombre.CssClass = "detalles"
            lblNumero.Text = CType(dtNuevo(0).numero, String)
            lblLetra.Text = CType(dtNuevo(0).letra, String)
            lblAno.Text = CType(dtNuevo(0).ano, String)
            lblNotaAc.Text = CType(dtNuevo(0).tienta_ac, String)
            lblNotaAP.Text = CType(dtNuevo(0).tienta_ap, String)
            lblPelaje.Text = CType(dtNuevo(0).pelaje1, String)
            lblHierro.Text = CType(dtNuevo(0).hierro, String)
            lkBoton.Visible = True
            hfCampo.Value = CType(dtNuevo(0).AnimalId, String)
            'imgDetalle.Visible = True
            'imgDetalle.NavigateUrl = sCriasPage + CType(dtNuevo(0).AnimalId, String)
            'imgDetalle.CssClass = "crias"
        Else
            hlNombre.Text = strNoRegistrado
            hlNombre.CssClass = ""
            hlNombre.NavigateUrl = ""
            If dtAnterior.Rows.Count > 0 Then
                lblNumero.Text = CType(dtAnterior(0).no_madre, String)
                lblLetra.Text = CType(dtAnterior(0).ltra_madre, String)
                lblAno.Text = CType(dtAnterior(0).ano_madre, String)
            Else
                lblNumero.Text = ""
                lblLetra.Text = ""
                lblAno.Text = ""
            End If
            lblNotaAc.Text = ""
            lblNotaAP.Text = ""
            lblPelaje.Text = ""
            lblHierro.Text = ""
            lkBoton.Visible = False
            hfCampo.Value = "0"
            'imgDetalle.Visible = False
        End If
    End Sub
    Protected Sub NivelToro(ByRef dtAnterior As GenealogiaDataTable, ByRef dtNuevo As GenealogiaDataTable, _
                            ByRef hlNombre As HyperLink, _
                            ByRef lblNumero As Label, ByRef lblLetra As Label, _
                            ByRef lblAno As Label, ByRef lblNotaAc As Label, _
                            ByRef lblNotaAP As Label, ByRef lblPelaje As Label, _
                            ByRef lblHierro As Label, ByRef lkBoton As ImageButton, ByRef hfCampo As HiddenField)

        If dtNuevo.Rows.Count > 0 Then
            hlNombre.Text = CType(dtNuevo(0).nombre, String)
            'hlNombre.NavigateUrl = sEditPage + CType(dtNuevo(0).AnimalId, String)
            'hlNombre.CssClass = "detalles"
            lblNumero.Text = CType(dtNuevo(0).numero, String)
            lblLetra.Text = CType(dtNuevo(0).letra, String)
            lblAno.Text = CType(dtNuevo(0).ano, String)
            lblNotaAc.Text = CType(dtNuevo(0).tienta_ac, String)
            lblNotaAP.Text = CType(dtNuevo(0).tienta_ap, String)
            lblPelaje.Text = CType(dtNuevo(0).pelaje1, String)
            lblHierro.Text = CType(dtNuevo(0).hierro, String)
            lkBoton.Visible = True
            hfCampo.Value = CType(dtNuevo(0).AnimalId, String)
            'imgDetalle.Visible = True
            'imgDetalle.NavigateUrl = sCriasPage + CType(dtNuevo(0).AnimalId, String)
            'imgDetalle.CssClass = "crias"
        Else
            hlNombre.Text = strNoRegistrado
            hlNombre.CssClass = ""
            hlNombre.CssClass = ""
            hlNombre.NavigateUrl = ""
            If dtAnterior.Rows.Count > 0 Then
                lblNumero.Text = CType(dtAnterior(0).no_padre, String)
                lblLetra.Text = CType(dtAnterior(0).ltra_padre, String)
                lblAno.Text = CType(dtAnterior(0).ano_padre, String)
            Else
                lblNumero.Text = ""
                lblLetra.Text = ""
                lblAno.Text = ""
            End If
            lblNotaAc.Text = ""
            lblNotaAP.Text = ""
            lblPelaje.Text = ""
            lblHierro.Text = ""
            lkBoton.Visible = False
            hfCampo.Value = "0"
            'imgDetalle.Visible = False
        End If
    End Sub
#End Region

#Region "Botones Avance"

    Protected Sub imgAvanza2_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles imgAvanza2.Click
        iAnimal = CType(hfCampo2.Value, Integer)
        Call DoGenealogia(iAnimal)
    End Sub

    Protected Sub imgAvanza3_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles imgAvanza3.Click
        iAnimal = CType(hfCampo3.Value, Integer)
        Call DoGenealogia(iAnimal)
    End Sub

    Protected Sub imgAvanza4_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles imgAvanza4.Click
        iAnimal = CType(hfCampo4.Value, Integer)
        Call DoGenealogia(iAnimal)
    End Sub

    Protected Sub imgAvanza5_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles imgAvanza5.Click
        iAnimal = CType(hfCampo5.Value, Integer)
        Call DoGenealogia(iAnimal)
    End Sub

    Protected Sub imgAvanza6_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles imgAvanza6.Click
        iAnimal = CType(hfCampo6.Value, Integer)
        Call DoGenealogia(iAnimal)
    End Sub

    Protected Sub imgAvanza7_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles imgAvanza7.Click
        iAnimal = CType(hfCampo7.Value, Integer)
        Call DoGenealogia(iAnimal)
    End Sub

    Protected Sub imgAvanza8_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles imgAvanza8.Click
        iAnimal = CType(hfCampo8.Value, Integer)
        Call DoGenealogia(iAnimal)
    End Sub

    Protected Sub imgAvanza9_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles imgAvanza9.Click
        iAnimal = CType(hfCampo9.Value, Integer)
        Call DoGenealogia(iAnimal)
    End Sub

    Protected Sub imgAvanza10_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles imgAvanza10.Click
        iAnimal = CType(hfCampo10.Value, Integer)
        Call DoGenealogia(iAnimal)
    End Sub

    Protected Sub imgAvanza11_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles imgAvanza11.Click
        iAnimal = CType(hfCampo11.Value, Integer)
        Call DoGenealogia(iAnimal)
    End Sub

    Protected Sub imgAvanza12_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles imgAvanza12.Click
        iAnimal = CType(hfCampo12.Value, Integer)
        Call DoGenealogia(iAnimal)
    End Sub

    Protected Sub imgAvanza13_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles imgAvanza13.Click
        iAnimal = CType(hfCampo13.Value, Integer)
        Call DoGenealogia(iAnimal)
    End Sub

    Protected Sub imgAvanza14_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles imgAvanza14.Click
        iAnimal = CType(hfCampo14.Value, Integer)
        Call DoGenealogia(iAnimal)
    End Sub

    Protected Sub imgAvanza15_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles imgAvanza15.Click
        iAnimal = CType(hfCampo15.Value, Integer)
        Call DoGenealogia(iAnimal)
    End Sub

    Protected Sub imgAvanza16_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles imgAvanza16.Click
        iAnimal = CType(hfCampo16.Value, Integer)
        Call DoGenealogia(iAnimal)
    End Sub

    Protected Sub imgAvanza17_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles imgAvanza17.Click
        iAnimal = CType(hfCampo17.Value, Integer)
        Call DoGenealogia(iAnimal)
    End Sub

    Protected Sub imgAvanza18_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles imgAvanza18.Click
        iAnimal = CType(hfCampo18.Value, Integer)
        Call DoGenealogia(iAnimal)
    End Sub

    Protected Sub imgAvanza19_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles imgAvanza19.Click
        iAnimal = CType(hfCampo19.Value, Integer)
        Call DoGenealogia(iAnimal)
    End Sub

    Protected Sub imgAvanza20_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles imgAvanza20.Click
        iAnimal = CType(hfCampo20.Value, Integer)
        Call DoGenealogia(iAnimal)
    End Sub

    Protected Sub imgAvanza21_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles imgAvanza21.Click
        iAnimal = CType(hfCampo21.Value, Integer)
        Call DoGenealogia(iAnimal)
    End Sub

    Protected Sub imgAvanza22_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles imgAvanza22.Click
        iAnimal = CType(hfCampo22.Value, Integer)
        Call DoGenealogia(iAnimal)
    End Sub

    Protected Sub imgAvanza23_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles imgAvanza23.Click
        iAnimal = CType(hfCampo23.Value, Integer)
        Call DoGenealogia(iAnimal)
    End Sub

    Protected Sub imgAvanza24_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles imgAvanza24.Click
        iAnimal = CType(hfCampo24.Value, Integer)
        Call DoGenealogia(iAnimal)
    End Sub

    Protected Sub imgAvanza25_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles imgAvanza25.Click
        iAnimal = CType(hfCampo25.Value, Integer)
        Call DoGenealogia(iAnimal)
    End Sub

    Protected Sub imgAvanza26_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles imgAvanza26.Click
        iAnimal = CType(hfCampo26.Value, Integer)
        Call DoGenealogia(iAnimal)
    End Sub

    Protected Sub imgAvanza27_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles imgAvanza27.Click
        iAnimal = CType(hfCampo27.Value, Integer)
        Call DoGenealogia(iAnimal)
    End Sub

    Protected Sub imgAvanza28_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles imgAvanza28.Click
        iAnimal = CType(hfCampo28.Value, Integer)
        Call DoGenealogia(iAnimal)
    End Sub

    Protected Sub imgAvanza29_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles imgAvanza29.Click
        iAnimal = CType(hfCampo29.Value, Integer)
        Call DoGenealogia(iAnimal)
    End Sub

    Protected Sub imgAvanza30_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles imgAvanza30.Click
        iAnimal = CType(hfCampo30.Value, Integer)
        Call DoGenealogia(iAnimal)
    End Sub

    Protected Sub imgAvanza31_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles imgAvanza31.Click
        iAnimal = CType(hfCampo31.Value, Integer)
        Call DoGenealogia(iAnimal)
    End Sub


#End Region
    '' Regresar a la pantalla principal
    Protected Sub imgPrincipal1_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles imgPrincipal1.Click
        iAnimal = CType(Request.QueryString("animal"), Integer)
        Call DoGenealogia(iAnimal)
    End Sub
End Class
